﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CUiFLEXErrorForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.UpdateContinuousMfg;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands;

public class CUiFLEXErrorForm : TxForm
{
  private const int DOWN_ARROW_IMG_INDEX = 0;
  private const int UP_ARROW_IMG_INDEX = 1;
  private Button m_abortButton;
  private Button m_continueButton;
  private Button m_detailsButton;
  private Label m_errorMessage;
  private PictureBox pictureBox1;
  private ImageList imageList1;
  private IContainer components;
  private RichTextBox m_detailsTextBox;
  private bool m_detailsDisplayed = true;

  public CUiFLEXErrorForm()
  {
    this.InitializeComponent();
    this.CollapseForm();
    this.SetButtonsState(CUiFLEXErrorForm.ButtonsState.Both);
  }

  private void InitializeComponent()
  {
    this.components = (IContainer) new Container();
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiFLEXErrorForm));
    this.pictureBox1 = new PictureBox();
    this.m_abortButton = new Button();
    this.m_continueButton = new Button();
    this.m_detailsButton = new Button();
    this.imageList1 = new ImageList(this.components);
    this.m_errorMessage = new Label();
    this.m_detailsTextBox = new RichTextBox();
    ((ISupportInitialize) this.pictureBox1).BeginInit();
    ((Control) this).SuspendLayout();
    componentResourceManager.ApplyResources((object) this.pictureBox1, "pictureBox1");
    this.pictureBox1.Name = "pictureBox1";
    this.pictureBox1.TabStop = false;
    this.m_abortButton.DialogResult = DialogResult.Abort;
    componentResourceManager.ApplyResources((object) this.m_abortButton, "m_abortButton");
    this.m_abortButton.Name = "m_abortButton";
    this.m_abortButton.UseVisualStyleBackColor = true;
    this.m_continueButton.DialogResult = DialogResult.OK;
    componentResourceManager.ApplyResources((object) this.m_continueButton, "m_continueButton");
    this.m_continueButton.Name = "m_continueButton";
    this.m_continueButton.UseVisualStyleBackColor = true;
    componentResourceManager.ApplyResources((object) this.m_detailsButton, "m_detailsButton");
    this.m_detailsButton.ImageList = this.imageList1;
    this.m_detailsButton.Name = "m_detailsButton";
    this.m_detailsButton.UseVisualStyleBackColor = true;
    this.m_detailsButton.Click += new EventHandler(this.m_detailsButton_Click);
    this.imageList1.ImageStream = (ImageListStreamer) componentResourceManager.GetObject("imageList1.ImageStream");
    this.imageList1.TransparentColor = Color.Transparent;
    this.imageList1.Images.SetKeyName(0, "down1.ico");
    this.imageList1.Images.SetKeyName(1, "up1.ico");
    componentResourceManager.ApplyResources((object) this.m_errorMessage, "m_errorMessage");
    this.m_errorMessage.Name = "m_errorMessage";
    componentResourceManager.ApplyResources((object) this.m_detailsTextBox, "m_detailsTextBox");
    this.m_detailsTextBox.Name = "m_detailsTextBox";
    this.m_detailsTextBox.ReadOnly = true;
    this.m_detailsTextBox.Text = UCMStringTable.UMC_Verify;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((Form) this).ControlBox = false;
    ((Control) this).Controls.Add((Control) this.m_detailsTextBox);
    ((Control) this).Controls.Add((Control) this.m_errorMessage);
    ((Control) this).Controls.Add((Control) this.m_detailsButton);
    ((Control) this).Controls.Add((Control) this.m_continueButton);
    ((Control) this).Controls.Add((Control) this.m_abortButton);
    ((Control) this).Controls.Add((Control) this.pictureBox1);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedToolWindow;
    ((Control) this).Name = nameof (CUiFLEXErrorForm);
    ((Form) this).ShowIcon = false;
    ((Form) this).Closing += new CancelEventHandler(this.CUiFLEXErrorForm_Closing);
    ((ISupportInitialize) this.pictureBox1).EndInit();
    ((Control) this).ResumeLayout(false);
  }

  public string ErrorText
  {
    set => this.m_errorMessage.Text = value;
  }

  public string DetailsText
  {
    set => this.m_detailsTextBox.Text = value;
  }

  public void AddDetailsText(string text) => this.m_detailsTextBox.Text += text;

  public void SetButtonsState(CUiFLEXErrorForm.ButtonsState state)
  {
    if (state == CUiFLEXErrorForm.ButtonsState.Both)
    {
      this.m_continueButton.Enabled = true;
      this.m_abortButton.Enabled = true;
    }
    else
    {
      this.m_continueButton.Enabled = false;
      this.m_abortButton.Enabled = true;
    }
  }

  private void m_detailsButton_Click(object sender, EventArgs e)
  {
    if (this.m_detailsDisplayed)
      this.CollapseForm();
    else
      this.ExpandForm();
  }

  private void CollapseForm()
  {
    ((Form) this).ClientSize = ((Form) this).ClientSize with
    {
      Height = this.m_detailsTextBox.Location.Y
    };
    this.m_detailsTextBox.Hide();
    this.m_detailsDisplayed = false;
    this.m_detailsButton.ImageIndex = 0;
  }

  private void ExpandForm()
  {
    ((Form) this).ClientSize = ((Form) this).ClientSize with
    {
      Height = this.m_detailsTextBox.Location.Y + this.m_detailsTextBox.Size.Height + 12
    };
    this.m_detailsTextBox.Show();
    this.m_detailsDisplayed = true;
    this.m_detailsButton.ImageIndex = 1;
  }

  private void CUiFLEXErrorForm_Closing(object sender, CancelEventArgs e) => this.CollapseForm();

  public enum ButtonsState
  {
    Both,
    AbortOnly,
  }
}
